﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartConference.Api.Applocations.IServices;
using SmartConference.Domain;
using SmartConference.ErrorCode;
using SmartConference.Infrastructure.Implements;
using SmartConference.Infrastructure.Interfaces;

namespace SmartConference.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "会议管理")]
    public class MeetingApprovalController : ControllerBase
    {
        private readonly IMeetingApprovalServices meetingApprovalServices;

        public MeetingApprovalController(IMeetingApprovalServices meetingApprovalServices)
        {
            this.meetingApprovalServices = meetingApprovalServices;
        }

        /// <summary>
        /// 会议审批列表
        /// </summary>
        /// <param name="state">审批状态</param>
        /// <param name="MeetingTheme">会议主题</param>
        /// <param name="RoomName">会议室名称</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<MeetingApprove>>> ShowApprove(int state, string? MeetingTheme, string? RoomName)
        {
            try
            {
                return await  meetingApprovalServices.ShowApprove(state, MeetingTheme, RoomName);

            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 审批会议
        /// </summary>
        /// <param name="id">会议id</param>
        /// <param name="state">通过结果</param>
        /// <param name="notes">原因</param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> ApprovalMeeting(int id, int state, string? notes)
        {
            try
            {
                return await meetingApprovalServices.ApprovalMeeting(id, state, notes);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
